package com.example.backend.common;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result {
    String code;
    String msg;
    Map<String, Object> data=new HashMap<>();

    public void setCode(String code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public String getCode() {
        return code;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public static Result success(String msg){
        Result result=new Result();
        result.setCode("200");
        result.setMsg(msg);
        return result;
    }
    public static Result error(String msg){
        Result result=new Result();
        result.setCode("300");
        result.setMsg(msg);
        return result;
    }
    public Result data(String key,Object data){
        this.data.put(key,data);
        return this;
    }
}
